import * as React from 'react';

// eslint-plugin-react-hooks
const { useEffect, useState } = React;
const WatchCount:React.FC = () => {
  const [count, setCount] = useState(0);

  useEffect(() => {
    const id = setInterval(() => {
      console.log('count', count)
    }, 2000)

    return function () {
      clearInterval(id)
    }
  }, [count])

  return <div>
    {
      count
    }
    <button onClick={() => setCount(count + 1)}>点击</button>
  </div>
}

export default WatchCount
